<?php

use common\models\User;
use yii\helpers\Html;
use kartik\builder\Form;
use kartik\form\ActiveForm;

/* @var $this yii\web\View */
/* @var $model backend\models\UserForm */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $roles yii\rbac\Role[] */
/* @var $permissions yii\rbac\Permission[] */

$title = Yii::t('common', 'add');
?>

<div class="panel panel-default">

    <div class="panel-heading"><?= $title; ?></div>
    <div class="panel-body">
        <?php

        $form = ActiveForm::begin([
            'type' => ActiveForm::TYPE_VERTICAL,
            'formConfig' => ['labelSpan' => 2, 'deviceSize' => ActiveForm::SIZE_SMALL],
        ]);

        echo Form::widget([
            'model' => $model,
            'form' => $form,
            'columns' => 2,
            'compactGrid' => true,
            'attributes' => [
                'username' => ['type' => Form::INPUT_TEXT],
                'email' => ['type' => Form::INPUT_TEXT],
                'mobile' => ['type' => Form::INPUT_TEXT],
                'password' => ['type' => Form::INPUT_TEXT],
                'status' => [
                    'type' => Form::INPUT_RADIO_LIST,
                    'items' => User::statuses(),
                    'options' => ['inline' => true]
                ],
                'roles' => [
                    'type' => Form::INPUT_MULTISELECT,
                    'items' => $roles,
                ],
            ]
        ]);
        ?>
        <div class="panel-footer text-right">
            <?= Html::submitButton('提交', ['class' => 'btn btn-primary']) ?>
        </div>
        <?php ActiveForm::end(); ?>
    </div>
</div>